<?php defined('SYSPATH') or die('No direct script access.');

class Model_Variant extends ORM
{
	protected $_belongs_to = array(
		'person' => array(),
	);
	
	public function link()
	{
		if($this->catalog == "copac")
			return "http://copac.ac.uk/search?au=".urlencode($this->name);
		else if($this->catalog == "rism")
			return "http://www.rism.org.uk/search/quick?person=".urlencode($this->name);
		else if($this->catalog == "blcollection")
			return "http://catalogue.bl.uk/F/?func=find-b&request=".urlencode($this->name)."&find_code=WNA";
		else
			return $this->link;
	}
	
	public function link_text()
	{
		$l = $this->link();
		
		if(strlen($l) < 80)
			return $l;
		else
			return substr($l, 0, 80)."...";
	}
}